package shop.product.controller;

import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import shop.common.entity.Product;
import shop.product.service.ProductService;

@RestController
@Slf4j
@Api(tags = "商品服务")
public class ProductController {

    @Autowired
    private ProductService productService;

    @GetMapping("/{pid}")
    @ApiOperation(value = "获取商品服务列表")
    public Product product(@PathVariable("pid") Integer pid) {
        Product product = productService.findById(pid);
        log.info("查询到商品:" + JSON.toJSONString(product));
        return product;
    }
}
